package com.cuit.jifver.weibo.data;

import android.content.Context;
import android.util.Log;

import com.cuit.jifver.weibo.inter.MyWeibo;
import com.cuit.jifver.weibo.model.TextMessage;
import com.cuit.jifver.weibo.net.OAuth;
import com.cuit.jifver.weibo.net.SyncHttp;
import com.cuit.jifver.weibo.util.Constants;

public class QqWeibo implements MyWeibo
{

	@Override
	public String publishTextMessage(Context context, TextMessage message)
	{
		String str = null;
		WeiboParameters params = new WeiboParameters();
		params.add("format", "json");
	
		params.add("content", message.getContent());
		
		params.add("clientip", "127.0.0.1");
		params.add(Constants.oauth.OAUTH_TOKEN, Weibo.getInstance().getAccessToken().getToken());
		//params.add("jing", "");
		//params.add("wei", "");
		
		try {
			str = OAuth.getPostParams(Constants.qq.URL_PUBLISH_TEXT_MESSAGE, "POST", params,Weibo.APP_SECRET, weibo.getAccessToken().getSecret());
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		SyncHttp http = new SyncHttp();
		try {
			str = http.httpPost(Constants.qq.URL_PUBLISH_TEXT_MESSAGE, str);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		/*try
		{
			str = weibo.request(context, Constants.qq.URL_PUBLISH_TEXT_MESSAGE, params, "POST", weibo.getAccessToken());
		} catch (WeiboException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		Log.e("", "publish_message="+str);
		return str;
	}

}
